if (true) {
    var a = 1;
}

console.log(a);

// let 关键字只在所处的块级作用域有效
if (true) {
    let b = 2;
    console.log(b);
}
// b is not defined
// console.log(b); 错误

for (let j = 0; j < 1; j++) {

}
// ReferenceError: j is not defined
// console.log(j);

// ReferenceError: j is not defined
// undefined 不是异常，就是一个 JavaScript 值
// 变量提升
console.log(c)
var c = 3;

// ReferenceError: Cannot access 'd' before initialization
// console.log(d)
// let d = 3;

var e = 10;
if (true) {
    console.log(e);     // ReferenceError: Cannot access 'e' before initialization
    let e = 20;
}